Skip to content

Differentiated graders, LLM-driven inference, and API improvements - #1

Merged
bigturtle679 merged 2 commits into
mainfrom
copilot/improve-inference-script
Apr 11, 2026
Merged

Differentiated graders, LLM-driven inference, and API improvements#1
bigturtle679 merged 2 commits into
mainfrom
copilot/improve-inference-script

Conversation

Copilot AI commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

Submission was functional but on the waiting list due to quality. The core issues: all five graders were identical pass-throughs, the inference agent used hardcoded action sequences with a dummy LLM call, and the API surface was minimal.

Graders (graders.py)

  • Each grader now applies difficulty-specific scoring adjustments instead of all delegating to grade_action identically
  • Easy: bonus for high-overlap safe edits. Medium: penalty for premature accept of risky terms. Hard/Hard+: penalty when hidden traps remain unresolved. Easy+: bonus for breach-notification language. Hard+: ownership-clarity bonus
  • Multipliers extracted to named constants (_HARD_UNRESOLVED_TRAP_PENALTY = 0.5, etc.)

Inference (inference.py)

  • Replaced rigid sequence-based strategy with two-phase LLM-driven approach: structured JSON analysis → optional rewrite call
  • Added expert system prompt for contract-negotiation domain with strict JSON schema output
  • Adaptive fallback: adjusts action choice based on previous step's reward; rule-based fallback when LLM unavailable
  • Retry logic with logging instead of silent except: pass
# LLM returns structured decisions instead of hardcoded sequences
{
  "risk_assessment": "Unlimited liability with no cap...",
  "risk_level": "HIGH",
  "recommended_action": "EDIT_CLAUSE",
  "rewritten_clause": "Vendor's aggregate liability shall be capped at..."
}

Environment (environment.py)

  • step() now delegates to task-specific graders via task.grade() instead of always using generic evaluate_action

Server (server/app.py)

  • Added GET /tasks endpoint exposing task metadata (id, clause_type, risk_level, has_grader)

Tests

  • 7 new tests (21 total): differentiated grader behavior per difficulty, /tasks endpoint, trap-resolution validation, all-tasks-have-graders assertion

Docs

  • README rewritten with tasks table, API reference, env vars, project structure

Copilot AI and others added 2 commits April 11, 2026 06:27
- Differentiate graders with task-specific scoring logic (easy/medium/hard/plus)
- Rewrite inference.py with genuine LLM-driven contract analysis using
  structured JSON output, system prompts, adaptive strategy, and retry logic
- Add /tasks endpoint to the FastAPI server with task metadata
- Add 7 new tests covering differentiated graders, tasks endpoint, and
  trap-resolution behaviour
- Improve README with comprehensive documentation
- Environment now uses task-specific graders via task.grade() in step()

Agent-Logs-Url: https://github.com/bigturtle679/Contract-Negotiation-Environment/sessions/625fe71f-e42b-4f9e-9af8-fd478becb5af

Co-authored-by: AbeerChaturvedi <171315954+AbeerChaturvedi@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants